<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js">
<!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
<meta charset="utf-8" />
<title>会员管理 - 所有下级</title>
<?php include($this->c['_homes']['_viewsHome'].'/_global/_head.php');?>
</head>
<!-- BEGIN BODY -->
<body class="page-header-fixed page-sidebar-fixed">
<!-- BEGIN HEADER -->
<?php include($this->c['_homes']['_viewsHome'].'/_global/head.php');?>
<!-- END HEADER -->
<div class="clearfix"></div>
<!-- BEGIN CONTAINER -->
<div class="page-container" > 
  <!-- BEGIN HORIZONTAL MENU PAGE SIDEBAR1 -->
  <?php include($this->c['_homes']['_viewsHome'].'/_global/menu.php');?>
  <!-- END BEGIN HORIZONTAL MENU PAGE SIDEBAR --> 
  <!-- BEGIN PAGE -->
  <div class="page-content"> 
    <!-- BEGIN PAGE HEADER-->
    <div class="row">
      <div class="col-md-12"> 
        <!-- BEGIN PAGE TITLE & BREADCRUMB-->
        <h3 class="page-title"> 所有下级 </h3>
        <ul class="page-breadcrumb breadcrumb">
          <li> <i class="icon-home"></i> <a href="/manage">后台</a> <i class="icon-angle-right"></i> </li>
          <li> 会员管理 <i class="icon-angle-right"></i> </li>
          <li> <a href="/member/memberlist">会员列表</a> <i class="icon-angle-right"></i> </li>
          <li>所有上级</li>
        </ul>
        <!-- END PAGE TITLE & BREADCRUMB--> 
      </div>
    </div>
    <!-- END PAGE HEADER--> 
    <!-- BEGIN PAGE CONTENT-->
    
    <div class="row">
      <div class="col-md-12"> 
        <!-- BEGIN SAMPLE FORM PORTLET-->
        <div class="portlet box blue">
          <div class="portlet-title">
            <div class="caption"> <i class="icon-reorder"></i> 所有上级 </div>
            <div class="tools"> <a href="" class="collapse"></a> </div>
          </div>
          <div class="portlet-body form">
            <form method="post" class="form-horizontal" action="">
              <div class="form-body">
                <div class="form-group">
                  <div class="col-md-12">
                    <h5> <img src="<?=str_replace("/0", "/132", $this->user['headimgurl']);?>" width="45">
                      <?=$this->grade[$this->user['member_gradeid']];?>
                      [
                      <?=$this->user['uid'];?>
                      ]
                      <?=$this->user['nickname'];?>
                      (<strong>
                      <?=$this->user['realname'];?>
                      </strong>) </h5>
                  </div>
                </div>
                <hr>
                <div class="form-group">
                  <div class="col-md-12">
                    <div class="lvld">
                      <?php
						if($this->data){
						  foreach($this->data as $k=> $r){
							?>
                          <div class="list" id="uid<?=$r['uid'];?>">
                            <div> <img src="<?=$r['headimgurl'];?>" width="45" data-uid="<?=$r['uid'];?>" data-act="no">
                              <?=$this->grade[$r['member_gradeid']];?>
                              [<?=$r['uid'];?>]
                              <?=$r['nickname'];?>
                              (<strong><?=$r['realname'];?></strong>) 本月：<?=$r['month_sales'];?> 业绩：<?=$r['total_sales'];?> 分成：<?=$r['total_commission'];?> 消费：<?=$r['total_buy'];?></div>
                          </div>
                      <?
						  }
						}
						?>
                    </div>
                  </div>
                </div>
              </div>
            </form>
          </div>
        </div>
        <!-- END SAMPLE FORM PORTLET--> 
        
      </div>
    </div>
    <!-- END PAGE CONTENT--> 
  </div>
  <!-- END PAGE --> 
</div>
<!-- END CONTAINER -->
<?php include($this->c['_homes']['_viewsHome'].'/_global/_footer.php');?>
<script>
jQuery(document).ready(function() {    
   App.init();
   
   $(".lvld .list div img").bind("click",function(){
		_getchild( $(this).attr("data-uid") );   
	});
   
});
var _grade = <?=json_encode($this->grade);?>;
function _getchild(uid){
	
	if( $("#child"+uid).length>0){
		$("#child"+uid).remove();
	}
	else{
	
		$.post("/member/ajax",{
			"act":"getchild",
			"uid":uid,
			"mr":Math.random()
			},
		function(msg){
			if(msg.code==200){
				var _html = '';
				
				$.each(msg.user,function(i,v){
					
					if(v.realname==null) v.realname='';
					_html +='<div class="list" id="uid'+v.uid+'">                            <div> <img src="'+v.headimgurl+'" width="45" data-uid="'+v.uid+'">                              '+_grade[v.member_gradeid]+'                              ['+v.uid+']                              '+v.nickname+'                              (<strong>'+v.realname+'</strong>) 本月：'+v.month_sales+' 业绩：'+v.total_sales+' 分成：'+v.total_commission+' 消费：'+v.total_buy+'</div>                          </div>';
				});
				
				_html = '<div class="lvld" id="child'+uid+'">'+_html+'</div>';
				$("#uid"+uid).after(_html);
				
				$(".lvld .list div img").unbind("click");
				$(".lvld .list div img").bind("click",function(){
					_getchild( $(this).attr("data-uid") );   
				});
				
			}
			else alert("没有下级用户");
		},"json");
	
	}
}
</script> 
<!-- END JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>